#include"Comm.hpp"

int main()
{
    int fd = open(PATH_NAME.c_str(), O_WRONLY);
    assert(fd != -1);
    Log("open nameed pipe file success", Debug) << endl;

    string mess;
    while(true)
    {
        cout << "Plese enter your message:> ";
        getline(cin, mess);
        // ssize_t sz = write(fd, mess.c_str(), mess.size());
        // //cout<<mess<<endl;
        // if(sz == 0)
        //     break;
        // else if(sz == -1)
        // {
        //     Log("write error", Error) << endl;
        //     exit(1);
        // }

        write(fd, mess.c_str(), mess.size());       //直接写入即可，无需做判断。否则，但只输入Enter时便会终止
    }
    Log("write over", Debug) << endl;
    close(fd);

    return 0;
}